const dayjs = require("dayjs");
// import dayjs from 'dayjs' // ES 2015
dayjs().format();
const filterTime = (val, comfromat = "YYYY-MM-DD") => {
  if (!isNull(val)) {
    val = parseInt(val);
    return dayjs(val).format(comfromat);
  } else {
    return "--";
  }
};
export const isNull = (date) => {
  if (!date) return true;
  if (JSON.stringify(date) === "{}") return true;
  if (JSON.stringify(date) === "[]") return true;
  return false;
};

export default (app) => {
  app.config.globalProperties.$filters = {
    filterTime: filterTime,
  };
};
